import { RouteRecordRaw } from 'vue-router';
import { Layout } from '@/router/constant';
import { SecurityScanOutlined } from '@vicons/antd';
import { renderIcon } from '@/utils/index';

/**
 * @param name 路由名称, 必须设置,且不能重名
 * @param meta 路由元信息（路由附带扩展信息）
 * @param redirect 重定向地址, 访问这个路由时,自定进行重定向
 * @param meta.disabled 禁用整个菜单
 * @param meta.title 菜单名称
 * @param meta.icon 菜单图标
 * @param meta.keepAlive 缓存该路由
 * @param meta.sort 排序越小越排前
 *
 * */
const routes: Array<RouteRecordRaw> = [
  {
    path: '/permission',
    name: 'permission',
    redirect: '/permission/users',
    component: Layout,
    meta: {
      title: '权限管理',
      icon: renderIcon(SecurityScanOutlined),
      sort: 2,
      permissions: ['permission_users','permission_roles','permission_menus'],
    },
    children: [
      {
        path: 'users',
        name: 'permission_users',
        meta: {
          title: '用户管理',
          permissions: ['permission_users'],
        },
        component: () => import('@/views/permission/users/users.vue'),
      },
      {
        path: 'roles',
        name: 'permission_roles',
        meta: {
          title: '角色管理',
          permissions: ['permission_roles'],
        },
        component: () => import('@/views/permission/role/role.vue'),
      },
      {
        path: 'menus',
        name: 'permission_menus',
        meta: {
          title: '菜单管理',
          permissions: ['permission_menus'],
        },
        component: () => import('@/views/permission/menu/menu.vue'),
      },
      {
        path: 'lockAccount',
        name: 'permission_lockAccount',
        meta: {
          title: '账号锁定',
          permissions: ['permission_lockAccount'],
        },
        component: () => import('@/views/permission/lock/lockRecord.vue'),
      },
    ],
  },
];

export default routes;
